package cn.hunqing.web.dto;

import java.io.Serializable;

import org.apache.commons.lang3.StringUtils;

import cn.hunqing.web.entity.Template;
import cn.hunqing.web.entity.WeddingInvitation;

public class InvitationForm implements Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = 5005103418302635786L;

	public static final String SUBMIT_PREVIEW = "preview";
	public static final String SUBMIT_SAVE = "save";
	
	public static final String ACTION_MAKE = "make";
	public static final String ACTION_EDIT = "edit";

	private String submit;
	/**
	 * action: make or edit
	 */
	private String action;
	
	private int templateId;
	
	private int weddingInvitationId;
	
	
    private String bridegroom;
    
    private String bride;

    private String weddingDay_Y;

    private String weddingDay_M;
    
    private String weddingDay_D;
    
    private String startTime_HR;
    
    private String startTime_MIN;
    
    private String hotel;
    
    private String address;
    
    private String coordinate;

    private boolean loveStoryPictureSelected;
    
    private String loveStoryPicture;
    
    private String loveStoryContent;

    private boolean loveStoryVideoSelected;
    
    private String loveStoryVideo;
    
    private String backgroundMusic;
    
    private String weddingPhotos;

	public String getSubmit() {
		return submit;
	}

	public void setSubmit(String submit) {
		this.submit = submit;
	}

	public String getAction() {
		return action;
	}

	public void setAction(String action) {
		this.action = action;
	}

	public int getTemplateId() {
		return templateId;
	}

	public void setTemplateId(int templateId) {
		this.templateId = templateId;
	}

	public int getWeddingInvitationId() {
		return weddingInvitationId;
	}

	public void setWeddingInvitationId(int weddingInvitationId) {
		this.weddingInvitationId = weddingInvitationId;
	}

	public String getBridegroom() {
		return bridegroom;
	}

	public void setBridegroom(String bridegroom) {
		this.bridegroom = bridegroom;
	}

	public String getBride() {
		return bride;
	}

	public void setBride(String bride) {
		this.bride = bride;
	}

	public String getWeddingDay_Y() {
		return weddingDay_Y;
	}

	public void setWeddingDay_Y(String weddingDay_Y) {
		this.weddingDay_Y = weddingDay_Y;
	}

	public String getWeddingDay_M() {
		return weddingDay_M;
	}

	public void setWeddingDay_M(String weddingDay_M) {
		this.weddingDay_M = weddingDay_M;
	}

	public String getWeddingDay_D() {
		return weddingDay_D;
	}

	public void setWeddingDay_D(String weddingDay_D) {
		this.weddingDay_D = weddingDay_D;
	}

	public String getStartTime_HR() {
		return startTime_HR;
	}

	public void setStartTime_HR(String startTime_HR) {
		this.startTime_HR = startTime_HR;
	}

	public String getStartTime_MIN() {
		return startTime_MIN;
	}

	public void setStartTime_MIN(String startTime_MIN) {
		this.startTime_MIN = startTime_MIN;
	}

	public String getHotel() {
		return hotel;
	}

	public void setHotel(String hotel) {
		this.hotel = hotel;
	}

	public String getAddress() {
		return address;
	}

	public void setAddress(String address) {
		this.address = address;
	}

	public String getCoordinate() {
		return coordinate;
	}

	public void setCoordinate(String coordinate) {
		this.coordinate = coordinate;
	}

	public String getLoveStoryPicture() {
		return loveStoryPicture;
	}

	public void setLoveStoryPicture(String loveStoryPicture) {
		this.loveStoryPicture = loveStoryPicture;
	}

	public String getLoveStoryVideo() {
		return loveStoryVideo;
	}

	public void setLoveStoryVideo(String loveStoryVideo) {
		this.loveStoryVideo = loveStoryVideo;
	}

	public String getLoveStoryContent() {
		return loveStoryContent;
	}

	public void setLoveStoryContent(String loveStoryContent) {
		this.loveStoryContent = loveStoryContent;
	}

	public String getBackgroundMusic() {
		return backgroundMusic;
	}

	public void setBackgroundMusic(String backgroundMusic) {
		this.backgroundMusic = backgroundMusic;
	}

	public String getWeddingPhotos() {
		return weddingPhotos;
	}

	public void setWeddingPhotos(String weddingPhotos) {
		this.weddingPhotos = weddingPhotos;
	}

	public boolean isLoveStoryPictureSelected() {
		return loveStoryPictureSelected;
	}

	public void setLoveStoryPictureSelected(boolean loveStoryPictureSelected) {
		this.loveStoryPictureSelected = loveStoryPictureSelected;
	}

	public boolean isLoveStoryVideoSelected() {
		return loveStoryVideoSelected;
	}

	public void setLoveStoryVideoSelected(boolean loveStoryVideoSelected) {
		this.loveStoryVideoSelected = loveStoryVideoSelected;
	}

	public static InvitationForm buildFrom(WeddingInvitation weddingInvitation, Template template) {
		InvitationForm result = new InvitationForm();
		result.setTemplateId(template.getId());
		result.setWeddingInvitationId(weddingInvitation.getId());
		result.setAddress(weddingInvitation.getAddress());
		result.setBackgroundMusic(weddingInvitation.getBackgroundMusic());
		result.setBride(weddingInvitation.getBride());
		result.setBridegroom(weddingInvitation.getBridegroom());
		result.setCoordinate(weddingInvitation.getCoordinate());
		result.setHotel(weddingInvitation.getHotel());
		result.setLoveStoryPictureSelected(weddingInvitation.getLoveStoryPictureSelected());
		result.setLoveStoryContent(weddingInvitation.getLoveStoryContent());
		result.setLoveStoryPicture(weddingInvitation.getLoveStoryPicture());
		result.setLoveStoryVideoSelected(weddingInvitation.getLoveStoryVideoSelected());
		result.setLoveStoryVideo(weddingInvitation.getLoveStoryVideo());
		result.setWeddingPhotos(weddingInvitation.getWeddingPhotos());
		result.setWeddingDay_Y(weddingInvitation.getWeddingDay_Y());
		result.setWeddingDay_M(weddingInvitation.getWeddingDay_M());
		result.setWeddingDay_D(weddingInvitation.getWeddingDay_D());
		result.setStartTime_HR(weddingInvitation.getStartTime_HR());
		result.setStartTime_MIN(weddingInvitation.getStartTime_MIN());

//		result.setWeddingDate(weddingInvitation.getWeddingDay_Y()+"-"+weddingInvitation.getWeddingDay_M()+"-"+weddingInvitation.getWeddingDay_D());  
//    	result.setWeddingTime(weddingInvitation.getStartTime_HR()+":"+weddingInvitation.getStartTime_MIN());
		return result;
	}
    

	public static WeddingInvitation extract(InvitationForm invitationForm){
		WeddingInvitation result = new WeddingInvitation();
		result.setAddress(StringUtils.trimToNull(invitationForm.getAddress()));
		result.setBackgroundMusic(StringUtils.trimToNull(invitationForm.getBackgroundMusic()));
		result.setBride(StringUtils.trimToNull(invitationForm.getBride()));
		result.setBridegroom(StringUtils.trimToNull(invitationForm.getBridegroom()));
		result.setCoordinate(StringUtils.trimToNull(invitationForm.getCoordinate()));
//		result.setHall(invitationForm.get);
		result.setHotel(StringUtils.trimToNull(invitationForm.getHotel()));
		result.setLoveStoryContent(invitationForm.getLoveStoryContent());
		result.setLoveStoryPictureSelected(invitationForm.isLoveStoryPictureSelected());
		result.setLoveStoryVideoSelected(invitationForm.isLoveStoryVideoSelected());
		result.setLoveStoryPicture(StringUtils.trimToNull(invitationForm.getLoveStoryPicture()));
		result.setLoveStoryVideo(StringUtils.trimToNull(invitationForm.getLoveStoryVideo()));
		result.setWeddingPhotos(StringUtils.trimToNull(invitationForm.getWeddingPhotos()));
		result.setWeddingDay_Y(invitationForm.getWeddingDay_Y());
		result.setWeddingDay_M(invitationForm.getWeddingDay_M());
		result.setWeddingDay_D(invitationForm.getWeddingDay_D());
//		if(!StringUtils.isEmpty(invitationForm.getWeddingDate())){
//			DateFormat format1 = new SimpleDateFormat("yyyy-MM-dd");  
//			try {
//				Date weddingDate = format1.parse(invitationForm.getWeddingDate());
//				result.setWeddingDay_Y(String.format("%tY", weddingDate));   
//				result.setWeddingDay_M(String.format("%tm", weddingDate));   
//			    result.setWeddingDay_D(String.format("%td", weddingDate));  
//			} catch (ParseException e) {
//				// TODO Auto-generated catch block
//				e.printStackTrace();
//			} 
//		}
//		if(!StringUtils.isEmpty(invitationForm.getWeddingTime())){
//			DateFormat format1 = new SimpleDateFormat("HH:mm");  
//			try {
//				Date weddingDate = format1.parse(invitationForm.getWeddingTime());
//				result.setStartTime_HR(String.format("%tH", weddingDate));   
//				result.setStartTime_MIN(String.format("%tM", weddingDate));   
//			} catch (ParseException e) {
//				// TODO Auto-generated catch block
//				e.printStackTrace();
//			} 
//		}

		result.setStartTime_HR(invitationForm.getStartTime_HR());
		result.setStartTime_MIN(invitationForm.getStartTime_MIN());
		result.setTemplateId(invitationForm.getTemplateId());
		return result;
	}
    
	public static TemplateSimpleDto convert(InvitationForm invitationForm){
		TemplateSimpleDto result = new TemplateSimpleDto();
//		result.set(invitationForm.getBride());
//		result.setBridegroom(invitationForm.getBridegroom());
////		result.setWeddingHall(invitationForm.get);
//		result.setWeddingHotel(invitationForm.getHotel());
//		
//		result.setTemplateId(invitationForm.getTemplateId());
////		result.setUserId(userId);
//		result.setWeddingDay(invitationForm.getWeddingDay_Y() + "-" + invitationForm.getWeddingDay_M() + "-" + invitationForm.getWeddingDay_D());
		return result;
	}
}
